Skip to content

Conversation

@joe-clickhouse
Copy link
Contributor

Summary

This PR introduces a backwards-compatible enhancement to automatically generate a UUID4 query_id client-side by default when not explicitly provided. This will greatly aid in correlating application logs with ClickHouse query logs during debugging, performance investigations, incident response, etc.

  • Client now generates a UUID v4 query_id for every query/command/insert operation
  • User-provided query_id values are always respected. This will not override
  • Centralized in _raw_request to cover all query paths (query, query_df, query_arrow, raw_query, command, insert, etc.)

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

Closes #596

@joe-clickhouse joe-clickhouse linked an issue Dec 4, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the ClickHouse client to automatically generate UUID v4 query_id values for all queries when not explicitly provided, improving observability and debugging capabilities by enabling correlation between application and ClickHouse query logs.

  • Added autogenerate_query_id setting (default: True) to control automatic query ID generation
  • Centralized query ID generation in _raw_request method to cover all query paths
  • Added comprehensive test coverage for auto-generation, manual override, and query log verification

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
clickhouse_connect/common.py Registers new autogenerate_query_id global setting with default value True
clickhouse_connect/driver/httpclient.py Adds constructor parameter and implements query ID auto-generation in _raw_request
tests/integration_tests/test_client.py Adds UUID v4 validation helper and comprehensive test coverage for query ID behavior
CHANGELOG.md Documents the new auto-generation feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

joe-clickhouse and others added 2 commits December 5, 2025 09:03
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Joe S. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Always generate query_id if not set

2 participants